#include<iostream>
#include<string>

using namespace std;

class Operation
{
public:
	Operation(){}
	virtual ~Operation(){}

	void SetNum(double A,double B)
	{
		NumA=A;
		NumB=B;
	}

	double GetNumA()
	{
		return NumA;
	}

	double GetNumB()
	{
		return NumB;
	}

	virtual double Result()
	{


		return 0;
	}

private:
	double NumA;
	double NumB;
};

class Add:public Operation

{
public:
	Add(){}
	~Add(){}

	double Result()
	{
		return (GetNumA()+GetNumB());
	}

};

class Sub:public Operation

{
public:
	Sub(){}
	~Sub(){}

	double Result()
	{
		return (GetNumA()-GetNumB());
	}

};

class Operator_Factory
{
public:
	Operator_Factory(){}
	virtual ~ Operator_Factory(){}
	virtual Operation * Create_Operation(){

		return NULL;
	}

};

class AddFactory:public Operator_Factory
{
public:
	AddFactory(){}
	~AddFactory(){}
	Operation * Create_Operation()
	{
		return new Add;
	}
};

class SubFactory:public Operator_Factory
{
public:
	SubFactory(){}
	~SubFactory(){}
	Operation * Create_Operation()
	{
		return new Sub;
	}
};

================================================================

#include "Head.h"

int main(void)
{
	cout<<"The factory model"<<endl;

	double A=10;
	double B=20;
	
	Operator_Factory * Oper=new AddFactory;
	Operation *op=Oper->Create_Operation();
	op->SetNum(A,B);
	cout<<op->Result();



	return 0;
}
